package com.t2c.tibetantochinese.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.t2c.tibetantochinese.views.CustomDialog;


/**
 * Created by zoulu on 16/3/2.
 * fragment基类
 */
public abstract class BaseFragment extends Fragment{

    private CustomDialog mLoadingDialog;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflater.inflate(getContentViewResId(), null);
        return rootView;
    }

    protected abstract int getContentViewResId();


    /**
     * 网络请求过程开始
     */
    protected void startLoadingProgress(String hint){
        mLoadingDialog = new CustomDialog(getActivity(), CustomDialog.DialogType.Loading);
        mLoadingDialog.setLoadingText(hint);
        mLoadingDialog.show();
    }

    /**
     * 网络请求结束
     */
    protected void stopLoadingProgress(){
        if (mLoadingDialog != null && mLoadingDialog.isShowing()){
            mLoadingDialog.dismiss();
            mLoadingDialog = null;
        }
    }

}
